package com.cold.demo.web.config.handlemapping.testcontroller;

import com.cold.demo.web.config.handlemapping.Primary;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author: zyc
 */
@Controller
public class MyTest2Controller {


    @RequestMapping("/my/test2")
    @Primary(value = -1, replaceUrl = "/my/test")
    @ResponseBody
    public Object test2(HttpServletRequest request) {
        return "/my/test2 访问成功";
    }


    @GetMapping("/my/test3")
    @Primary(value = 0, replaceUrl = "/my/test2")
    @ResponseBody
    public Object test3(HttpServletRequest request) {
        return "/my/test3 访问成功";
    }



    @GetMapping("/my/test4")
    @Primary(value = -4, replaceUrl = "/my/test4")
    public void test4(HttpServletRequest request, HttpServletResponse response) throws IOException {
        response.sendRedirect("http://www.baidu.com");
    }
}
